<!--
 * @Author: 卡卡 1071780426@qq.com
 * @Date: 2022-12-02 13:13:25
 * @LastEditors: CNN 969682281@qq.com
 * @LastEditTime: 2024-01-04 13:27:04
 * @FilePath: \backstage - 副本\src\views\aa.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="department" id="department">
    <div class="department_right">
      <div class="app-container-btn">
        <el-button @click="goBack">返回</el-button>
      </div>
      <div
        class="text_table multistageHeader TensionRealTimeFirstLevel"
        style="height: 100%"
      >
       <el-table
          :data="tableDataLook"
          :span-method="objectSpanMethod"
          border
          style="width: 100%; height: 100%"
        >
          <el-table-column prop="fNote" label="过程" align="center" width="75">
            <template slot-scope="scope">
              <el-button
                @click="openDialog(scope.row)"
                @cell-dblclick="openDialog"
                type="text"
                size="small"
                style="padding: 0 !important; margin: 0"
              >
                {{ scope.row.fNote }}
              </el-button>
            </template>
          </el-table-column>
          <el-table-column
            prop="fNambername"
            label="孔号"
            align="center"
            width="70"
          >
          </el-table-column>
          <el-table-column
            prop="fTensioningdates"
            label="张拉时间"
            align="center"
            width="150"
          >
          </el-table-column>
          <el-table-column
            prop="fMachinename"
            label="张拉仪"
            align="center"
            width="65"
          >
          </el-table-column>
          <el-table-column
            prop="fRecordproject"
            label="记录项目"
            align="center"
            width="110"
          >
          </el-table-column>
          <el-table-column label="张拉阶段" align="center">
            <el-table-column
              prop="fOriginalstroke"
              label="初始行程"
              align="center"
              width="70"
            >
            </el-table-column>
            <el-table-column
              prop="fFirststroke"
              label="第一行程"
              align="center"
              width="70"
            >
            </el-table-column>
            <el-table-column
              prop="fSecondstroke"
              label="第二行程"
              align="center"
              width="70"
            >
            </el-table-column>
            <el-table-column
              prop="fThirdstroke"
              label="第三行程"
              align="center"
              width="70"
            >
            </el-table-column>
            <el-table-column
              prop="fFourthstroke"
              label="第四行程"
              align="center"
              width="70"
            >
            </el-table-column>
          </el-table-column>
          <el-table-column
            prop="fConclusion"
            label="实测结论"
            align="center"
            width="70"
          >
          </el-table-column>
          <el-table-column
            prop="fDesigntension"
            label="设计张力(KN)"
            align="center"
            width="100"
          >
          </el-table-column>
          <el-table-column
            prop="fOvertensionrate"
            label="超张百分比(%)"
            align="center"
            width="110"
          >
            <template slot-scope="scope">
              <el-button
                size="mini"
                :type="scope.row.OvertensionrateBtnType"
                :class="scope.row.OvertensionrateBtnType"
              >
                {{ scope.row.fOvertensionrate }}
              </el-button>
            </template>
          </el-table-column>
          <el-table-column
            prop="fDesignelongation"
            label="设计伸长量(mm)"
            align="center"
            width="115"
          >
          </el-table-column>
          <el-table-column
            prop="fTotalelongation"
            label="总伸长量(mm)"
            align="center"
            width="110"
          >
          </el-table-column>
          <el-table-column
            prop="fElongationdeviation"
            label="延伸量误差(%)"
            align="center"
            width="110"
          >
            <template slot-scope="scope">
              <el-button
                size="mini"
                :type="scope.row.ElongationdeviationBtnType"
                :class="scope.row.ElongationdeviationBtnType"
              >
                {{ scope.row.fElongationdeviation }}
              </el-button>
            </template>
          </el-table-column>
          <el-table-column
            prop="fRetraction"
            label="回缩量(mm)"
            align="center"
            width="100"
          >
            <template slot-scope="scope">
              <el-button
                size="mini"
                :type="scope.row.RetractionBtnType"
                :class="scope.row.RetractionBtnType"
              >
                {{ scope.row.fRetraction }}
              </el-button>
            </template>
          </el-table-column>
          <el-table-column
            prop="fHoldingtime"
            label="持荷时间(s)"
            align="center"
            width="100"
          >
            <template slot-scope="scope">
              <el-button
                size="mini"
                :type="scope.row.HoldingtimeBtnType"
                :class="scope.row.HoldingtimeBtnType"
              >
                {{ scope.row.fHoldingtime }}
              </el-button>
            </template>
          </el-table-column>
          <el-table-column
            prop="fWarninglevel"
            label="预警级别"
            align="center"
            width="100"
          >
            <template slot-scope="scope">
              <el-button
                size="mini"
                :type="scope.row.btnType"
                :class="scope.row.btnType"
              >
                {{ scope.row.fWarninglevelText }}
              </el-button>
            </template>
          </el-table-column>
          <el-table-column
            prop="fHandlesituation"
            label="断、滑丝及处理情况"
            align="center"
            width="140"
          >
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>
    
<script>
import {
  getTensioningProcess, //查看--过程数据
} from "@/api/request.js";
export default {
  name: "TensionExceedDataFirstLevel",
  components: {},
  data() {
    return {
      name: "TensionExceedDataFirstLevel", //按钮配置页面代号
      editLoading: false,
      userInfo: {}, //登录用户
      tableDataLook: [],
      // 过程数据-详情
      materialRow: null, //选择过程数据当前行数据
      materialGetList: {
        namberId: "", // 孔号id
        page: 1, // 当前页码
        pageSize: 15, // 每页显示条数
      }, //调取过程数据详情接口传参
    };
  },
  mounted() {
    this.yj_viewForm();
    this.userInfo = JSON.parse(sessionStorage.getItem("GxEmbedded_userInfo"));
  },
  methods: {
    goBack() {
      this.$router.back();
    },
    btnRole(name) {
      // 按钮权限
      var btnList = [];
      var ModuleList = JSON.parse(
        sessionStorage.getItem("GxEmbedded_ModuleList")
      );
      if (ModuleList.length > 0) {
        ModuleList.map((item) => {
          if (item.fEncode == name) {
            btnList = item.modulebuttonList;
          }
        });
        var btnStr = [];
        btnList.map((item) => {
          btnStr.push(item.fEncode);
        });
        // this.yj_view = btnStr.includes("yj_view");
      } else {
        // this.yj_view = true;
      }
    },
    yj_viewForm(row) {
      if (this.$route.query.data != "" && this.$route.query.data != null) {
        this.tableDataLook = [];
        getTensioningProcess({
          beamId: this.$route.query.data,
          fCompanyid: this.$route.query.fCompanyid,
        })
          .then((res) => {
            if (res.errcode == 0) {
              var that = this;
              this.tableDataLook = res.data.tensioningProcess;
              that.tableDataLook.map((item) => {
                // 预警级别
                if (item.fWarninglevel == 0) {
                  item.fWarninglevelText = "正常";
                  item.btnType = "success";
                } else if (item.fWarninglevel == 1) {
                  item.fWarninglevelText = "一级";
                  item.btnType = "plain";
                } else if (item.fWarninglevel == 2) {
                  item.fWarninglevelText = "二级";
                  item.btnType = "warning";
                } else if (item.fWarninglevel == 3) {
                  item.fWarninglevelText = "三级";
                  item.btnType = "danger";
                } else if (item.fWarninglevel == 4) {
                  item.fWarninglevelText = "四级";
                  item.btnType = "purple";
                }

                // 超张百分比
                if (item.fOvertensionratewarninglevel == 0) {
                  item.OvertensionrateBtnType = "success";
                } else if (item.fOvertensionratewarninglevel == 1) {
                  item.OvertensionrateBtnType = "plain";
                } else if (item.fOvertensionratewarninglevel == 2) {
                  item.OvertensionrateBtnType = "warning";
                } else if (item.fOvertensionratewarninglevel == 3) {
                  item.OvertensionrateBtnType = "danger";
                } else if (item.fOvertensionratewarninglevel == 4) {
                  item.OvertensionrateBtnType = "purple";
                }
                //延伸量误差
                if (item.fElongationdeviationwarninglevel == 0) {
                  item.ElongationdeviationBtnType = "success";
                } else if (item.fElongationdeviationwarninglevel == 1) {
                  item.ElongationdeviationBtnType = "plain";
                } else if (item.fElongationdeviationwarninglevel == 2) {
                  item.ElongationdeviationBtnType = "warning";
                } else if (item.fElongationdeviationwarninglevel == 3) {
                  item.ElongationdeviationBtnType = "danger";
                } else if (item.fElongationdeviationwarninglevel == 4) {
                  item.ElongationdeviationBtnType = "purple";
                }
                // 回缩量
                if (item.fRetractionwarninglevel == 0) {
                  item.RetractionBtnType = "success";
                } else if (item.fRetractionwarninglevel == 1) {
                  item.RetractionBtnType = "plain";
                } else if (item.fRetractionwarninglevel == 2) {
                  item.RetractionBtnType = "warning";
                } else if (item.fRetractionwarninglevel == 3) {
                  item.RetractionBtnType = "danger";
                } else if (item.fRetractionwarninglevel == 4) {
                  item.RetractionBtnType = "purple";
                }
                // 持荷时间
                if (item.fHoldingtimewarninglevel == 0) {
                  item.HoldingtimeBtnType = "success";
                } else if (item.fHoldingtimewarninglevel == 1) {
                  item.HoldingtimeBtnType = "plain";
                } else if (item.fHoldingtimewarninglevel == 2) {
                  item.HoldingtimeBtnType = "warning";
                } else if (item.fHoldingtimewarninglevel == 3) {
                  item.HoldingtimeBtnType = "danger";
                } else if (item.fHoldingtimewarninglevel == 4) {
                  item.HoldingtimeBtnType = "purple";
                }
              });
            } else {
              this.$message.error(res.msg);
            }
          })
          .catch((error) => {
            this.$message.error(error.msg);
          });
      } else {
        return this.$message.error("请先选择需要查看的数据");
      }
    },

    // 查看列表---行合并
    objectSpanMethod({ row, column, rowIndex, columnIndex }) {
      if (
        columnIndex === 0 ||
        columnIndex === 1 ||
        columnIndex === 2 ||
        columnIndex === 19
      ) {
        if (rowIndex % 6 === 0) {
          return {
            rowspan: 6,
            colspan: 1,
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0,
          };
        }
      } else if (
        columnIndex === 3 ||
        columnIndex === 11 ||
        columnIndex === 12 ||
        columnIndex === 13 ||
        columnIndex === 14 ||
        columnIndex === 15 ||
        columnIndex === 16 ||
        columnIndex === 17 ||
        columnIndex === 18
      ) {
        if (rowIndex % 3 === 0) {
          return {
            rowspan: 3,
            colspan: 1,
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0,
          };
        }
      }
      return row, column, rowIndex, columnIndex;
    },
    // 点击详情列表---过程数据
    openDialog(row) {
      this.materialRow = row;
      
      this.materialGetList = {
        namberId: row.fNamberid, // 孔号id
        page: 1, // 当前页码
        pageSize: 15, // 每页显示条数
      };
      this.$router.push({
        path: "/tensionManage/tensionExceedDatasecondLevel",
        query: {
          data: row.fNamberid,
          fCompanyid: this.$route.query.fCompanyid,
        },
      });
    },
  },
};
</script>
<style scoped lang='less'></style>